const {
  db
} = require('../core/db.js');

const {
  Sequelize,
  Model
} = require('sequelize');

const classicFields = {
  image: {
    type: Sequelize.STRING,
    // get () {
    //   return this.getDataValue('image')
    // }
  },
  content: Sequelize.STRING,
  pubdate: Sequelize.DATEONLY,
  fav_nums: {
    type: Sequelize.INTEGER,
    default: 0
  },
  title: Sequelize.STRING,
  type: Sequelize.TINYINT,
}

class Movie extends Model {

};

Movie.init(classicFields, {
  sequelize: db,
  tableName: 'movie'
});

class Sentence extends Model {

};

Sentence.init(classicFields, {
  sequelize: db,
  tableName: 'sentence'
});

class Music extends Model {

};

const musicFields = Object.assign({
  url: Sequelize.STRING
}, classicFields)

Music.init(musicFields, {
  sequelize: db,
  tableName: 'music'
});

// Music.sync();
// Sentence.sync();
// Movie.sync();
// Sequelize.sycn();
module.exports = {
  Movie,
  Sentence,
  Music
}